class Solution {
    public:
        bool isPerfectSquare(int num) {
            int l=1;
            int r=num;
            while(l<=r){
                int mid=l+((r-l)>>1);
                long long sqrt=mid*mid;
                if(sqrt<num){
                    l=mid+1;
                }else if(sqrt>num){
                    r=mid-1;
                }else{
                    return true;
                }
            }
            return false;
        }
    };